package org.springboot.szsrcb.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springboot.szsrcb.entity.Req_base_info;
import org.springboot.szsrcb.entity.Req_bill;
import org.springboot.szsrcb.srvice.Req_bill_Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/test")
public class TestController_input {

	private static final Logger logger = LoggerFactory.getLogger(TestController_input.class);

	@Autowired
	private Req_bill_Service req_bill_Service;

	/*
	 * @RequestMapping("/test_new") public String test_new() {
	 * logger.info("test_new");
	 * 
	 * // model.addAttribute("name", name); return "test_new"; }
	 */

	@RequestMapping(value = "/test_new", method = { RequestMethod.GET })
	public String req_new(HttpServletRequest request, Model model, HttpSession httpSession) {

		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {
			logger.info("access /test/test_new ");
			// logger.info("request.getMethod:"+request.getMethod());
			// Req_bill req_b=new Req_bill();
			// req_b.setReq_title("frank test");
			// model.addAttribute("Req_bill",req_b);
			String g_req_id = request.getParameter("req_id");
			model.addAttribute("req_id", g_req_id);
			return "test_new";
		} else {
			logger.info("access login page.");
			return "/login";
		}
	}

	@RequestMapping(value = "/test_new_details")
	public String test_new_details(HttpServletRequest request, Model model, HttpSession httpSession) {
		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {
			logger.info("access /test/test_new ");
			// logger.info("request.getMethod:"+request.getMethod());
			// Req_bill req_b=new Req_bill();
			// req_b.setReq_title("frank test");
			// model.addAttribute("Req_bill",req_b);
			String g_req_id = request.getParameter("req_id");
			model.addAttribute("req_id", g_req_id);
			return "test_new";
		} else {
			logger.info("access login page.");
			return "/login";
		}
	}

	@RequestMapping("/test_new_select_req")
	public String test_new_select_req(HttpSession httpSession) {
		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {
			logger.info("test_new_select_req");

			// model.addAttribute("name", name);
			return "test_new_select_req";
		} else {
			logger.info("access login page.");
			return "/login";
		}
	}

	@RequestMapping("/test_new_select_req_no_reqno")
	public String test_new_select_req_no_reqno(HttpSession httpSession) {
		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {
			logger.info("test_new_select_req_no_reqno");
			// model.addAttribute("name", name);
			return "test_new_select_req_no_reqno";
		} else {
			logger.info("access login page.");
			return "/login";
		}
	}

	@RequestMapping("/test_new_select_req_have_reqno")
	public String test_new_select_req_have_reqno(HttpSession httpSession) {
		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {

			logger.info("test_new_select_req_have_reqno");

			// model.addAttribute("name", name);
			return "test_new_select_req_have_reqno";
		} else {
			logger.info("access login page.");
			return "/login";
		}
	}
}
